<%--
  - Author		:	이 영호(Youngho Lee)	
  --%>
<%@ page language="java" %>
<%@ page contentType="text/html; charset=utf-8" %>
<%@ page pageEncoding="utf-8" %>
<%@ include file="/WEB-INF/pages/includes/taglibs.jspf" %>
<%@ include file="/WEB-INF/pages/includes/variables.jspf" %>
<%@ include file="/WEB-INF/pages/includes/doctype.jspf" %>
<html>
	<head>
<%@ include file="/WEB-INF/pages/includes/metatags.jspf" %>
		<title><fmt:message key="pages.title" /></title>
		<link rel="stylesheet" type="text/css" href="<c:url value="${dirStyles}/common.css" />" />

		<script type="text/javascript" src="<c:url value="${dirScripts}/jquery-1.7.2.min.js" />"></script>
		<script type="text/javascript" src="<c:url value="${dirScripts}/jquery-ui-1.8.21.custom.min.js" />"></script>
		<script type="text/javascript">
			$(function(){
				$(".popupWrap").draggable({ cursor: "pointer", handle: ".pTitle" });
			});
			
			function goAction(idx, pw){
				document.detailFrm.idx.value=idx;
				
				if(pw){
					$(".pBoard").show();	
				}else {
					document.detailFrm.submit();
				}
				
			}
			
			function chkPw(){
				if(($("#password").val()).replace(/\s/g, '') == ""){
					alert("[비밀번호]를 입력하세요.");
					$("#password").focus();
					return false;
				}else{
					document.detailFrm.password.value=$("#password").val();
					document.detailFrm.submit();	
				}
			}
			
			function goPage(page){
				document.searchFrm.page.value = page;
				document.searchFrm.submit();
			}

		</script>
	</head>
	<body>
<%@ include file="/WEB-INF/pages/includes/header.jsp" %>
		<div class="bodyWrap">
<%@ include file="/WEB-INF/pages/includes/left.jsp" %>
			<div class="contWrap">
				<div class="contMenuTitle">
					<img src="<c:url value="${dirImages}/subtit_04_2.gif" />" title="문의하기(체험단)" alt="문의하기(체험단)">
				</div>
				<div class="secTitle">
					<img src="<c:url value="${dirImages}/icon.png" />" title="문의하기(체험단)" alt="문의하기(체험단)" > 문의하기(체험단)
					<div style="float: right;">
						<form name="searchFrm" method="post" action="<c:url value="/tester/qna.do" />">
							<input type="hidden" name="maxnum" value="${maxnum}" />
							<input type="hidden" name="page" value="${page}" />
							<select name="searchType">
								<option value="title" <c:if test="${param.searchType eq 'title'}"> selected="selected" </c:if>>제목</option>
								<option value="cont" <c:if test="${param.searchType eq 'cont'}"> selected="selected" </c:if>>내용</option>
								<option value="name" <c:if test="${param.searchType eq 'name'}"> selected="selected" </c:if>>작성자</option>
							</select>
							<input type="text" name="searchWord" value="${param.searchWord}" />
							<input type="submit" class="btn btn_search" alt="검색" title="검색" value="">
						</form>
					</div>
				</div>
				<table class="listTbl linked">
					<thead>
						<tr>
							<th>번호</th>
							<th>제목</th>
							<th>작성자</th>
							<th>날짜</th>
							<th class="lastTh">조회</th>
						</tr>
					</thead>
					<tbody>
						<c:forEach items="${boardList}" var="board" varStatus="stat">
							<tr onclick="javascript:goAction(${board.idx}<c:if test="${not empty board.password}">, true</c:if>);">
								<td>${boardListTotalCnt - stat.index - (maxnum*(page-1))}</td>
								<td><c:out value="${board.title}" /><c:if test="${not empty board.password}"> <img src="<c:url value="${dirImages}/board_lock_icon.png" />"></c:if></td>
								<td><c:out value="${board.createdNm}" /></td>
								<td>
									<c:catch var="e">
										<fmt:parseDate var="date" pattern="yyyy-MM-dd HH:mm:ss" value="${board.createdTime}" />
										<fmt:formatDate value="${date}" pattern="yyyy.MM.dd" />
									</c:catch>
									<c:if test="${not empty e}">
										${board.createdTime}
									</c:if>
								</td>
								<td><c:out value="${board.viewCnt}" /></td>
							</tr>
						</c:forEach>
					</tbody>
					<c:if test="${boardListTotalCnt eq 0}">
						<tfoot>
							<tr>
								<td colspan="5">문의내용이 없습니다.</td>
							</tr>
						</tfoot>
					</c:if>
				</table>
				<c:if test="${boardListTotalCnt ne 0}">
					<div class="pagingWrap">
						<jsp:include page="/WEB-INF/pages/includes/paging.jsp">
							<jsp:param name="totalNum" value="${boardListTotalCnt}" />
							<jsp:param name="pageListCnt" value="${maxnum}" />
							<jsp:param name="pageGrpCnt" value="10" />
							<jsp:param name="pageIdx" value="${page}" />
						</jsp:include>
					</div>
				</c:if>
				<div class="btnWrap rightBtnWrap">
					<input type="button" class="btn btn_write" alt="글쓰기" title="글쓰기" onclick="javascript:document.regFrm.submit();">
				</div>
			</div>
		</div>
		<div class="popupWrap pBoard" style="display: none;">
			<div class="pTitle">
				비밀번호 입력
				<div class="pClose btn" onclick="javascript:$('.pBoard').hide();"></div>
			</div>
			<div class="pCont">
				<p style="text-align: center;line-height: 25px;">
					비밀번호를 입력하세요.<br />
					(숫자 4자리 입력)<br />
					<input type="password" id="password" title="비밀번호" alt="비밀번호" maxlength="4" />
				</p>
			</div>
			<div class="btnWrap centerBtnWrap">
				<input type="button" class="btn btn_ok" alt="확인" title="확인" onclick="javascript:chkPw();">
			</div>
		</div>
		<form name="regFrm" method="post" action="<c:url value="/tester/formQna.do" />" style="display: none;">
			<input type="hidden" name="maxnum" value="${maxnum}" />
			<input type="hidden" name="page" value="${page}" />
			<input type="hidden" name="boardType" value="qna" />
			<input type="hidden" name="searchType" value="${param.searchType}" />
			<input type="hidden" name="searchWord" value="${param.searchWord}" />
		</form>
		<form name="detailFrm" method="post" action="<c:url value="/tester/detailQna.do" />" style="display: none;">
			<input type="hidden" name="idx" value="" />
			<input type="hidden" name="password" value="" />
			<input type="hidden" name="maxnum" value="${maxnum}" />
			<input type="hidden" name="page" value="${page}" />
			<input type="hidden" name="searchType" value="${param.searchType}" />
			<input type="hidden" name="searchWord" value="${param.searchWord}" />
		</form>
<%@ include file="/WEB-INF/pages/includes/footer.jsp" %>
	</body>
</html> 